<script>
	import Header from "@/components/Header.vue"
	import Modal from "@/components/Modal.vue"
	export default {
		components: {
			Modal,
			Header
		},
		data() {
			return {
				type: null,
				title: "",
				titles: {
					1: "支出记录",
					2: "收入记录",
					3: "提现记录"
				},
				finance_type_id:0,
				ymd:'',
				arr:[],
				arr_id:[],
				arr_name:[],
				list:[]
			}
		},
		onLoad(options) {
			if (options.type) {
				this.type = options.type
				this.title = this.titles[options.type]
				this.types();
				this.lists();
			}
		},
		methods: {
			types(){
				var that = this
				uni.request({
					url:getApp().globalData.host+'/api/Fund/getFinanceType',
					data:{
						finance_type:that.type
					},
					header: {
						memberid:uni.getStorageSync('member_id'),
						membertoken:uni.getStorageSync('member_token'),
					},
					success:(r) => {
						var arr_id = []
						var arr_name = []
						that.arr = r.data.data.list
						for(var i=0;i<that.arr.length;i++){
							arr_id.push(that.arr[i].finance_type_id)
							arr_name.push(that.arr[i].name)
						}
						that.arr_id = arr_id
						that.arr_name = arr_name
					},
				})
			},
			
			lists(){
				var that = this
				uni.request({
					url:getApp().globalData.host+'/api/Fund/getFinanceList',
					data:{
						finance_type:that.type,finance_type_id:that.finance_type_id,ymd:that.ymd,page:1,nums:1000
					},
					header: {
						memberid:uni.getStorageSync('member_id'),
						membertoken:uni.getStorageSync('member_token'),
					},
					success:(r) => {
						that.list = r.data.data.list
						console.log(that.list)
					},
				})
			},
			change_type(e){
				var that = this
				that.finance_type_id = that.arr_id[e.detail.value]
				that.lists();
			},
			change_ymd(e){
				var that = this
				that.ymd = e.detail.value
				that.lists();
			},
			all(){
				var that = this
				that.finance_type_id = 0
				that.ymd = ''
				that.lists();
			}
		}
	}
</script>
<template>
	<view class="custom-bg h-full overflow-hidden">
		<Header :title="title"></Header>
		<div class="p-30 h-full flex flex-col">

			<div class="between flex-shirnk-0">
				<div class="item custom-input center w-200 h-70" @click="all()">
					全部
				</div>
				<div class="item bg-white rounded-20 center w-200 h-70 ">
					<picker mode="selector" :range="arr_name" @change="change_type">
						<div class="flex">
							类型
							<image src="/static/my/down2.png" mode="widthFix" class="w-30 ml-8 "></image>
						</div>
					</picker>
				</div>
				<div class="item  bg-white center rounded-20 w-200 h-70">
					<picker mode="date" @change="change_ymd">
						<div class="flex">
							日期
							<image src="/static/my/down2.png" mode="widthFix" class="w-30 ml-8 "></image>
						</div>
					</picker>
				</div>
			</div>

			<div class="mt-30 flex-1" style="overflow: auto;">
				<div class="bg-white p-30 rounded-22 mb-20" v-for="item in list"
					@click="go('/pages/my/wallet/detail?type='+type+'&finance_id='+item.finance_id)">
					<div class="between">
						<div class="fz28 text-gray-29" style="width: 70%;">{{item.zs_content}}</div>
						<div class="fz26 text-gray-16 font-bold">{{item.ys_content}}</div>
					</div>
					<div class="between mt-20 ">
						<div class="fz26 text-gray-a7" style="width: 60%;">{{item.zx_content}}</div>
						<div class="fz26 text-gray-a7">{{item.yx_content}}</div>
					</div>
				</div>
				<nomore v-if="list.length==0"></nomore>

				<div style="height:300rpx;"></div>

			</div>


		</div>

	</view>


</template>



<style>
	page {
		height: 100%;
	}

	.submit {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-shadow: 0 -10rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	.custom-bg {
		min-height: 100%;
	}

	.avatar-group {
		position: relative;
	}

	page {
		height: 100%;
		background-color: #F8F8F8;
	}
</style>